#pragma once
#include <msg/response.h>

struct RouterResponse
{
    static response make_response(request req, response_code code, std::span<char const> body = {}){
        response resp;
        response_head head {req.get_head().op, req.get_head().req_id, code};

        resp.set_sender(req.get_router_info().to);
        resp.set_receiver(req.get_router_info().from);
        resp.set_head(head);
        resp.set_body(const_cast<char*>(body.data()), body.size());
        // resp.set_data_size(sizeof(response_head) + body.size());

        if (body.empty() == false)
            resp.set_body(const_cast<char*>(body.data()), body.size());

        return resp;
    }
};

